package com.xiangyi.teachingsystem.entity.vo;

import lombok.Data;

import java.sql.Timestamp;


@Data
public class Result {

    private Integer status;
    private String message;
    private Object data;
    private Timestamp timestamp;

    //防止被外部实例化
    private Result() {
        this.timestamp = new Timestamp(System.currentTimeMillis());
    }

    private Result(Integer status, String message) {
        this.status = status;
        this.message = message;
        this.timestamp = new Timestamp(System.currentTimeMillis());
    }

    public static Result success(String message) {
        return new Result(200, message);
    }

    public static Result failure(String message) {
        return new Result(100, message);
    }

    public static Result notAllow(String message) {
        return new Result(401, message);
    }

    public static Result notAuth(String message) {
        return new Result(500, message);
    }


    public Result setData(Object data) {
        this.data = data;
        return this;
    }

}